{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "aeba9e17",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello!\n"
     ]
    }
   ],
   "source": [
    " def greet_user():    #定义一个函数,关键词为\"def\",函数名为\"greet_user\",最后以“：”结尾\n",
    "     \"\"\"显示简单的问候语\"\"\"    #描述函数的具体功能\n",
    "     print(\"Hello!\")         #函数体的代码块，用于实现函数功能\n",
    " \n",
    " greet_user()         #调用函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "3860d9c1",
   "metadata": {},
   "outputs": [],
   "source": [
    "def greet_user():\n",
    "    \"\"\"问候语函数\"\"\"\n",
    "    print(\"hello world!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "bbd370dd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello world!\n"
     ]
    }
   ],
   "source": [
    "greet_user()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "b5d3ca15",
   "metadata": {},
   "outputs": [],
   "source": [
    "def greet_user(username):\n",
    "    \"\"\"问候语函数\"\"\"\n",
    "    print(\"hello\",username)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "5c946262",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello Jim\n"
     ]
    }
   ],
   "source": [
    "greet_user(\"Jim\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "72487fdf",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 实践\n",
    "def NFU_NEWS_URL(分类,页码):\n",
    "    \"\"\"可以快速查询广州南方学院的新闻页面链接\n",
    "       分类:[\"xxyw\",\"xydt\",\"tzgg\",\"ztb\",\"gxdt\"]\n",
    "       页码:[113,106,37,27,29]\n",
    "    \"\"\"\n",
    "    for i in range(页码):\n",
    "        print(\"https://www.nfu.edu.cn/\"+分类+\"/index\"+str(i)+\".html\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "49d6ac81",
   "metadata": {},
   "outputs": [],
   "source": [
    "import nfu_crawl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "13147c30",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function NFU_NEWS_URL in module nfu_crawl:\n",
      "\n",
      "NFU_NEWS_URL(分类, 页码)\n",
      "    可以快速查询广州南方学院的新闻页面链接\n",
      "    分类:[\"xxyw\",\"xydt\",\"tzgg\",\"ztb\",\"gxdt\"]\n",
      "    页码:[113,106,37,27,29]\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(nfu_crawl.NFU_NEWS_URL)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "68eaed13",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://www.nfu.edu.cn/xydt/index0.html\n",
      "https://www.nfu.edu.cn/xydt/index1.html\n",
      "https://www.nfu.edu.cn/xydt/index2.html\n",
      "https://www.nfu.edu.cn/xydt/index3.html\n",
      "https://www.nfu.edu.cn/xydt/index4.html\n",
      "https://www.nfu.edu.cn/xydt/index5.html\n",
      "https://www.nfu.edu.cn/xydt/index6.html\n",
      "https://www.nfu.edu.cn/xydt/index7.html\n",
      "https://www.nfu.edu.cn/xydt/index8.html\n",
      "https://www.nfu.edu.cn/xydt/index9.html\n",
      "https://www.nfu.edu.cn/xydt/index10.html\n",
      "https://www.nfu.edu.cn/xydt/index11.html\n",
      "https://www.nfu.edu.cn/xydt/index12.html\n",
      "https://www.nfu.edu.cn/xydt/index13.html\n",
      "https://www.nfu.edu.cn/xydt/index14.html\n",
      "https://www.nfu.edu.cn/xydt/index15.html\n",
      "https://www.nfu.edu.cn/xydt/index16.html\n",
      "https://www.nfu.edu.cn/xydt/index17.html\n",
      "https://www.nfu.edu.cn/xydt/index18.html\n",
      "https://www.nfu.edu.cn/xydt/index19.html\n",
      "https://www.nfu.edu.cn/xydt/index20.html\n",
      "https://www.nfu.edu.cn/xydt/index21.html\n",
      "https://www.nfu.edu.cn/xydt/index22.html\n",
      "https://www.nfu.edu.cn/xydt/index23.html\n",
      "https://www.nfu.edu.cn/xydt/index24.html\n",
      "https://www.nfu.edu.cn/xydt/index25.html\n",
      "https://www.nfu.edu.cn/xydt/index26.html\n",
      "https://www.nfu.edu.cn/xydt/index27.html\n",
      "https://www.nfu.edu.cn/xydt/index28.html\n",
      "https://www.nfu.edu.cn/xydt/index29.html\n",
      "https://www.nfu.edu.cn/xydt/index30.html\n",
      "https://www.nfu.edu.cn/xydt/index31.html\n",
      "https://www.nfu.edu.cn/xydt/index32.html\n",
      "https://www.nfu.edu.cn/xydt/index33.html\n",
      "https://www.nfu.edu.cn/xydt/index34.html\n",
      "https://www.nfu.edu.cn/xydt/index35.html\n",
      "https://www.nfu.edu.cn/xydt/index36.html\n",
      "https://www.nfu.edu.cn/xydt/index37.html\n",
      "https://www.nfu.edu.cn/xydt/index38.html\n",
      "https://www.nfu.edu.cn/xydt/index39.html\n",
      "https://www.nfu.edu.cn/xydt/index40.html\n",
      "https://www.nfu.edu.cn/xydt/index41.html\n",
      "https://www.nfu.edu.cn/xydt/index42.html\n",
      "https://www.nfu.edu.cn/xydt/index43.html\n",
      "https://www.nfu.edu.cn/xydt/index44.html\n",
      "https://www.nfu.edu.cn/xydt/index45.html\n",
      "https://www.nfu.edu.cn/xydt/index46.html\n",
      "https://www.nfu.edu.cn/xydt/index47.html\n",
      "https://www.nfu.edu.cn/xydt/index48.html\n",
      "https://www.nfu.edu.cn/xydt/index49.html\n",
      "https://www.nfu.edu.cn/xydt/index50.html\n",
      "https://www.nfu.edu.cn/xydt/index51.html\n",
      "https://www.nfu.edu.cn/xydt/index52.html\n",
      "https://www.nfu.edu.cn/xydt/index53.html\n",
      "https://www.nfu.edu.cn/xydt/index54.html\n",
      "https://www.nfu.edu.cn/xydt/index55.html\n",
      "https://www.nfu.edu.cn/xydt/index56.html\n",
      "https://www.nfu.edu.cn/xydt/index57.html\n",
      "https://www.nfu.edu.cn/xydt/index58.html\n",
      "https://www.nfu.edu.cn/xydt/index59.html\n",
      "https://www.nfu.edu.cn/xydt/index60.html\n",
      "https://www.nfu.edu.cn/xydt/index61.html\n",
      "https://www.nfu.edu.cn/xydt/index62.html\n",
      "https://www.nfu.edu.cn/xydt/index63.html\n",
      "https://www.nfu.edu.cn/xydt/index64.html\n",
      "https://www.nfu.edu.cn/xydt/index65.html\n",
      "https://www.nfu.edu.cn/xydt/index66.html\n",
      "https://www.nfu.edu.cn/xydt/index67.html\n",
      "https://www.nfu.edu.cn/xydt/index68.html\n",
      "https://www.nfu.edu.cn/xydt/index69.html\n",
      "https://www.nfu.edu.cn/xydt/index70.html\n",
      "https://www.nfu.edu.cn/xydt/index71.html\n",
      "https://www.nfu.edu.cn/xydt/index72.html\n",
      "https://www.nfu.edu.cn/xydt/index73.html\n",
      "https://www.nfu.edu.cn/xydt/index74.html\n",
      "https://www.nfu.edu.cn/xydt/index75.html\n",
      "https://www.nfu.edu.cn/xydt/index76.html\n",
      "https://www.nfu.edu.cn/xydt/index77.html\n",
      "https://www.nfu.edu.cn/xydt/index78.html\n",
      "https://www.nfu.edu.cn/xydt/index79.html\n",
      "https://www.nfu.edu.cn/xydt/index80.html\n",
      "https://www.nfu.edu.cn/xydt/index81.html\n",
      "https://www.nfu.edu.cn/xydt/index82.html\n",
      "https://www.nfu.edu.cn/xydt/index83.html\n",
      "https://www.nfu.edu.cn/xydt/index84.html\n",
      "https://www.nfu.edu.cn/xydt/index85.html\n",
      "https://www.nfu.edu.cn/xydt/index86.html\n",
      "https://www.nfu.edu.cn/xydt/index87.html\n",
      "https://www.nfu.edu.cn/xydt/index88.html\n",
      "https://www.nfu.edu.cn/xydt/index89.html\n",
      "https://www.nfu.edu.cn/xydt/index90.html\n",
      "https://www.nfu.edu.cn/xydt/index91.html\n",
      "https://www.nfu.edu.cn/xydt/index92.html\n",
      "https://www.nfu.edu.cn/xydt/index93.html\n",
      "https://www.nfu.edu.cn/xydt/index94.html\n",
      "https://www.nfu.edu.cn/xydt/index95.html\n",
      "https://www.nfu.edu.cn/xydt/index96.html\n",
      "https://www.nfu.edu.cn/xydt/index97.html\n",
      "https://www.nfu.edu.cn/xydt/index98.html\n",
      "https://www.nfu.edu.cn/xydt/index99.html\n",
      "https://www.nfu.edu.cn/xydt/index100.html\n",
      "https://www.nfu.edu.cn/xydt/index101.html\n",
      "https://www.nfu.edu.cn/xydt/index102.html\n",
      "https://www.nfu.edu.cn/xydt/index103.html\n",
      "https://www.nfu.edu.cn/xydt/index104.html\n",
      "https://www.nfu.edu.cn/xydt/index105.html\n"
     ]
    }
   ],
   "source": [
    "nfu_crawl.NFU_NEWS_URL(\"xydt\",106)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "da1272b8",
   "metadata": {},
   "outputs": [],
   "source": [
    "def describe_pet(animal_type,pet_name):\n",
    "    \"\"\"显示宠物信息\"\"\"\n",
    "    print(\"\\nI have a\" + animal_type + \".\")\n",
    "    print(\"My\" + animal_type + \"'s name is \"+pet_name.title() + \".\")\n",
    "\n",
    "describe_pet('hamster','harry')\n",
    "describe_pet('cat','python')  #函数调用多次是一种效率极高的工作方式"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6d74adb1",
   "metadata": {},
   "source": [
    "## 关于实参和形参"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fac50372",
   "metadata": {},
   "outputs": [],
   "source": [
    "* positional argument(位置参数)\n",
    "* keyword argument(关键字参数)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "ce762c41",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "positional argument follows keyword argument (3733943091.py, line 6)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [22]\u001b[1;36m\u001b[0m\n\u001b[1;33m    func_test(x=1,2)\u001b[0m\n\u001b[1;37m                   ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m positional argument follows keyword argument\n"
     ]
    }
   ],
   "source": [
    "#eg1\n",
    "def func_test(x,y):\n",
    "    print(x)\n",
    "    print(y)\n",
    "    \n",
    "func_test(x=1,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "dc637795",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n"
     ]
    }
   ],
   "source": [
    "#eg2\n",
    "def func_test(x,y):\n",
    "    print(x)\n",
    "    print(y)\n",
    "    \n",
    "func_test(1,y=2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "9706c8a0",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "positional argument follows keyword argument (1697356429.py, line 6)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [24]\u001b[1;36m\u001b[0m\n\u001b[1;33m    func_test(1,y=2,3)\u001b[0m\n\u001b[1;37m                     ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m positional argument follows keyword argument\n"
     ]
    }
   ],
   "source": [
    "#eg3\n",
    "def func_test(x,y,z):\n",
    "    print(x)\n",
    "    print(y)\n",
    "    \n",
    "func_test(1,y=2,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "e10953e5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "#eg3\n",
    "def func_test(x,y,z):\n",
    "    print(x)\n",
    "    print(y)\n",
    "    \n",
    "func_test(1,3,z=2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "49816015",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "positional argument follows keyword argument (3466147257.py, line 6)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [21]\u001b[1;36m\u001b[0m\n\u001b[1;33m    func_test(x=1,2)      #？\u001b[0m\n\u001b[1;37m                   ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m positional argument follows keyword argument\n"
     ]
    }
   ],
   "source": [
    "#eg1\n",
    "def func_test(x,y):\n",
    "    print(x)\n",
    "    print(y)\n",
    "    \n",
    "func_test(x=1,2)      #？\n",
    "\n",
    "#eg2\n",
    "def func_test(x,y):\n",
    "    print(x)\n",
    "    print(y)\n",
    "    \n",
    "func_test(1,y=2)      #？\n",
    "\n",
    "#eg3\n",
    "def func_test(x,y,z):\n",
    "    print(x)\n",
    "    print(y)\n",
    "    \n",
    "func_test(1,y=2,3)      #？\n",
    "\n",
    "#结论？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "67f174bd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function NFU_NEWS_URL in module __main__:\n",
      "\n",
      "NFU_NEWS_URL(分类, 页码)\n",
      "    可以快速查询广州南方学院的新闻页面链接\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help (NFU_NEWS_URL)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "0c20125f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://www.nfu.edu.cn/xxyw/index0.html\n",
      "https://www.nfu.edu.cn/xxyw/index1.html\n",
      "https://www.nfu.edu.cn/xxyw/index2.html\n",
      "https://www.nfu.edu.cn/xxyw/index3.html\n",
      "https://www.nfu.edu.cn/xxyw/index4.html\n",
      "https://www.nfu.edu.cn/xxyw/index5.html\n",
      "https://www.nfu.edu.cn/xxyw/index6.html\n",
      "https://www.nfu.edu.cn/xxyw/index7.html\n",
      "https://www.nfu.edu.cn/xxyw/index8.html\n",
      "https://www.nfu.edu.cn/xxyw/index9.html\n",
      "https://www.nfu.edu.cn/xxyw/index10.html\n",
      "https://www.nfu.edu.cn/xxyw/index11.html\n",
      "https://www.nfu.edu.cn/xxyw/index12.html\n",
      "https://www.nfu.edu.cn/xxyw/index13.html\n",
      "https://www.nfu.edu.cn/xxyw/index14.html\n",
      "https://www.nfu.edu.cn/xxyw/index15.html\n",
      "https://www.nfu.edu.cn/xxyw/index16.html\n",
      "https://www.nfu.edu.cn/xxyw/index17.html\n",
      "https://www.nfu.edu.cn/xxyw/index18.html\n",
      "https://www.nfu.edu.cn/xxyw/index19.html\n",
      "https://www.nfu.edu.cn/xxyw/index20.html\n",
      "https://www.nfu.edu.cn/xxyw/index21.html\n",
      "https://www.nfu.edu.cn/xxyw/index22.html\n",
      "https://www.nfu.edu.cn/xxyw/index23.html\n",
      "https://www.nfu.edu.cn/xxyw/index24.html\n",
      "https://www.nfu.edu.cn/xxyw/index25.html\n",
      "https://www.nfu.edu.cn/xxyw/index26.html\n",
      "https://www.nfu.edu.cn/xxyw/index27.html\n",
      "https://www.nfu.edu.cn/xxyw/index28.html\n",
      "https://www.nfu.edu.cn/xxyw/index29.html\n",
      "https://www.nfu.edu.cn/xxyw/index30.html\n",
      "https://www.nfu.edu.cn/xxyw/index31.html\n",
      "https://www.nfu.edu.cn/xxyw/index32.html\n",
      "https://www.nfu.edu.cn/xxyw/index33.html\n",
      "https://www.nfu.edu.cn/xxyw/index34.html\n",
      "https://www.nfu.edu.cn/xxyw/index35.html\n",
      "https://www.nfu.edu.cn/xxyw/index36.html\n",
      "https://www.nfu.edu.cn/xxyw/index37.html\n",
      "https://www.nfu.edu.cn/xxyw/index38.html\n",
      "https://www.nfu.edu.cn/xxyw/index39.html\n",
      "https://www.nfu.edu.cn/xxyw/index40.html\n",
      "https://www.nfu.edu.cn/xxyw/index41.html\n",
      "https://www.nfu.edu.cn/xxyw/index42.html\n",
      "https://www.nfu.edu.cn/xxyw/index43.html\n",
      "https://www.nfu.edu.cn/xxyw/index44.html\n",
      "https://www.nfu.edu.cn/xxyw/index45.html\n",
      "https://www.nfu.edu.cn/xxyw/index46.html\n",
      "https://www.nfu.edu.cn/xxyw/index47.html\n",
      "https://www.nfu.edu.cn/xxyw/index48.html\n",
      "https://www.nfu.edu.cn/xxyw/index49.html\n",
      "https://www.nfu.edu.cn/xxyw/index50.html\n",
      "https://www.nfu.edu.cn/xxyw/index51.html\n",
      "https://www.nfu.edu.cn/xxyw/index52.html\n",
      "https://www.nfu.edu.cn/xxyw/index53.html\n",
      "https://www.nfu.edu.cn/xxyw/index54.html\n",
      "https://www.nfu.edu.cn/xxyw/index55.html\n",
      "https://www.nfu.edu.cn/xxyw/index56.html\n",
      "https://www.nfu.edu.cn/xxyw/index57.html\n",
      "https://www.nfu.edu.cn/xxyw/index58.html\n",
      "https://www.nfu.edu.cn/xxyw/index59.html\n",
      "https://www.nfu.edu.cn/xxyw/index60.html\n",
      "https://www.nfu.edu.cn/xxyw/index61.html\n",
      "https://www.nfu.edu.cn/xxyw/index62.html\n",
      "https://www.nfu.edu.cn/xxyw/index63.html\n",
      "https://www.nfu.edu.cn/xxyw/index64.html\n",
      "https://www.nfu.edu.cn/xxyw/index65.html\n",
      "https://www.nfu.edu.cn/xxyw/index66.html\n",
      "https://www.nfu.edu.cn/xxyw/index67.html\n",
      "https://www.nfu.edu.cn/xxyw/index68.html\n",
      "https://www.nfu.edu.cn/xxyw/index69.html\n",
      "https://www.nfu.edu.cn/xxyw/index70.html\n",
      "https://www.nfu.edu.cn/xxyw/index71.html\n",
      "https://www.nfu.edu.cn/xxyw/index72.html\n",
      "https://www.nfu.edu.cn/xxyw/index73.html\n",
      "https://www.nfu.edu.cn/xxyw/index74.html\n",
      "https://www.nfu.edu.cn/xxyw/index75.html\n",
      "https://www.nfu.edu.cn/xxyw/index76.html\n",
      "https://www.nfu.edu.cn/xxyw/index77.html\n",
      "https://www.nfu.edu.cn/xxyw/index78.html\n",
      "https://www.nfu.edu.cn/xxyw/index79.html\n",
      "https://www.nfu.edu.cn/xxyw/index80.html\n",
      "https://www.nfu.edu.cn/xxyw/index81.html\n",
      "https://www.nfu.edu.cn/xxyw/index82.html\n",
      "https://www.nfu.edu.cn/xxyw/index83.html\n",
      "https://www.nfu.edu.cn/xxyw/index84.html\n",
      "https://www.nfu.edu.cn/xxyw/index85.html\n",
      "https://www.nfu.edu.cn/xxyw/index86.html\n",
      "https://www.nfu.edu.cn/xxyw/index87.html\n",
      "https://www.nfu.edu.cn/xxyw/index88.html\n",
      "https://www.nfu.edu.cn/xxyw/index89.html\n",
      "https://www.nfu.edu.cn/xxyw/index90.html\n",
      "https://www.nfu.edu.cn/xxyw/index91.html\n",
      "https://www.nfu.edu.cn/xxyw/index92.html\n",
      "https://www.nfu.edu.cn/xxyw/index93.html\n",
      "https://www.nfu.edu.cn/xxyw/index94.html\n",
      "https://www.nfu.edu.cn/xxyw/index95.html\n",
      "https://www.nfu.edu.cn/xxyw/index96.html\n",
      "https://www.nfu.edu.cn/xxyw/index97.html\n",
      "https://www.nfu.edu.cn/xxyw/index98.html\n",
      "https://www.nfu.edu.cn/xxyw/index99.html\n",
      "https://www.nfu.edu.cn/xxyw/index100.html\n",
      "https://www.nfu.edu.cn/xxyw/index101.html\n",
      "https://www.nfu.edu.cn/xxyw/index102.html\n",
      "https://www.nfu.edu.cn/xxyw/index103.html\n",
      "https://www.nfu.edu.cn/xxyw/index104.html\n",
      "https://www.nfu.edu.cn/xxyw/index105.html\n",
      "https://www.nfu.edu.cn/xxyw/index106.html\n",
      "https://www.nfu.edu.cn/xxyw/index107.html\n",
      "https://www.nfu.edu.cn/xxyw/index108.html\n",
      "https://www.nfu.edu.cn/xxyw/index109.html\n",
      "https://www.nfu.edu.cn/xxyw/index110.html\n",
      "https://www.nfu.edu.cn/xxyw/index111.html\n",
      "https://www.nfu.edu.cn/xxyw/index112.html\n"
     ]
    }
   ],
   "source": [
    "NFU_NEWS_URL(\"xxyw\",113)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c8b7317f",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 模块"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "673e5486",
   "metadata": {},
   "source": [
    "* 对计算机而言： 函数必须有返回值（公理）\n",
    "* Python：返回值给了一个默认值（None）\n",
    "> 1.返回值的第一种情况：返回函数过程的计算结果\n",
    "> 2.返回值的第二种情况：返回函数过程运算的过程"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "28d7e1ff",
   "metadata": {},
   "outputs": [],
   "source": [
    "def func(x):\n",
    "    \"\"\"计算y=2x\"\"\"\n",
    "    y = 2*x\n",
    "    print(y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "cbe08333",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n",
      "None\n"
     ]
    }
   ],
   "source": [
    "print(func(2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "23223295",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
